package tests.testSingleton;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.util.ArrayList;

import org.junit.Test;

import singleton.Singleton;
import controller.UseCaseController;
import controller.UseCaseControllerImplementation;
import controller.data.Comment;
import controller.data.fundamental.TabItemCategory;
import controller.data.searchRevision.SearchRevisionResponse;

public class TestSingleton {

	@Test
	public void testInstance() {
		Singleton instance = Singleton.getInstance();
		assertTrue(instance instanceof Singleton);
		assertEquals(instance == Singleton.getInstance(), true);
	}

	@Test
	public void testSetAndGetObjects() {
		Singleton instance = Singleton.getInstance();

		// title
		assertEquals(instance.getTitle(), "");
		instance.setTitle("title1");
		assertEquals(instance.getTitle(), "title1");

		// comment
		assertEquals(instance.getComment(), "");
		instance.setComment("comment1");
		assertEquals(instance.getComment(), "comment1");

		// getGoForIt
		assertEquals(instance.getGoForIt, false);
		instance.setGetGoForIt(true);
		assertEquals(instance.getGoForIt, true);

		// commentText
		assertEquals(instance.getCommentText(), "");
		instance.setCommentText("commentText1");
		assertEquals(instance.getCommentText(), "commentText1");

		// documentText
		assertEquals(instance.getDocumentText(), "");
		instance.setDocumentText("doc1");
		assertEquals(instance.getDocumentText(), "doc1");

		// response
		assertEquals(instance.getResponse(), "");
		instance.setResponse("response");
		assertEquals(instance.getResponse(), "response");

		// searchString
		assertEquals(instance.getSearchString(), "");
		instance.setSearchString("search");
		assertEquals(instance.getSearchString(), "search");

		// tags
		assertEquals(instance.getTags(), "");
		instance.setTags("tags");
		assertEquals(instance.getTags(), "tags");

		// text
		assertEquals(instance.getText(), "");
		instance.setText("text");
		assertEquals(instance.getText(), "text");

		// actual Tab
		assertEquals(instance.getEmptyTab(), null);
		TabItemCategory tmp = new TabItemCategory("", "");
		instance.setEmptyTab(tmp);
		assertEquals(instance.getEmptyTab(), tmp);

		// selected Tab
		assertEquals(instance.getSelectedTab(), null);
		instance.setSelectedTab(tmp);
		assertEquals(instance.getSelectedTab(), tmp);

		// getCommentPrevious
		assertEquals(instance.getCommentPrevious(), null);
		instance.setCommentPrevious(new ArrayList<Comment>());
		assertEquals(instance.getCommentPrevious(), new ArrayList<Comment>());

		// listofdata
		assertEquals(instance.getListOfRevisions(), null);
		instance.setListOfRevisions(new ArrayList<SearchRevisionResponse>());
		assertEquals(instance.getListOfRevisions(),
				new ArrayList<SearchRevisionResponse>());

		// useCaseController
		assertEquals(instance.getUseCaseController(), null);
		UseCaseController use = new UseCaseControllerImplementation();
		instance.setUseCaseController(use);
		assertEquals(instance.getUseCaseController(), use);

	}

}
